package com.lyh.jnademo.controller;

import com.lyh.jnademo.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author lyh
 * @version 1.0
 * @date 2019/10/11
 */
@RestController
public class HelloWorld {

    @Autowired
    HelloWorldService helloWorldService;

    @Value("#{ new java.util.HashMap() }")
    Map<String, Object> mapJson;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map<String, Object> sum(@RequestBody Map<String, String> map) {
        System.out.println("map = " + map);
        int a = Integer.parseInt(map.get("a"));
        int b = Integer.parseInt(map.get("b"));
        int sum = helloWorldService.librayAdd(a, b);
        mapJson.put("msg",sum);
        return mapJson;
    }
}
